import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test11 {
    public static void main(String[] args) {
        System.out.println("--------1------");
        System.out.println("a".matches("[abc]"));
        System.out.println("b".matches("[abc]"));
        System.out.println("z".matches("[abc]"));
        System.out.println("ab".matches("[abc][abc]"));
        System.out.println("-----------2--------");
        System.out.println("a".matches("[^abc]"));
        System.out.println("b".matches("[^abc]"));
        System.out.println("a".matches("[a-d[m-p]]"));
        System.out.println("b".matches("[a-d[m-p]]"));
        System.out.println("m".matches("[a-d[m-p]]"));
        System.out.println("e".matches("[a-d[m-p]]"));
        System.out.println("-------3-------");
        System.out.println("0".matches("[a-z&&[def]]"));
        System.out.println("e".matches("[a-z&&[def]]"));
        System.out.println("-------4-------");
        System.out.println("a".matches("[a-z&&[^bc]]"));
        System.out.println("b".matches("[a-z&&[^bc]]"));
        System.out.println("0".matches("[a-z&&[^bc]]"));
        System.out.println("-----------5--------");
        System.out.println("a".matches("[a-z&&[^m-p]]"));
        System.out.println("m".matches("[a-z&&[^m-p]]"));
        System.out.println("-------6-------");
        System.out.println("q".matches("."));
        System.out.println("你".matches("."));
        System.out.println("-------7-------");
        System.out.println("a".matches("\\d"));
        System.out.println("3".matches("\\d"));
        System.out.println("-------8-------");
        System.out.println("z".matches("\\w"));
        System.out.println("你".matches("\\W"));
        System.out.println("\t".matches("\\s"));
        System.out.println("--------9----------");
        System.out.println("2442fsfsf".matches("\\w{6}"));
        System.out.println("23df".matches("[a-zA-Z0-9]{4}"));
        System.out.println("23dlf".matches("[\\w&&[^-]]{4}"));
        System.out.println("-----10------");
        String regex1="\\w+@[\\w&&[^w]]{2,6}(\\.[a-zA-Z]{2,3}){1,2}";
        System.out.println("2726974521@qq.com".matches(regex1));
        System.out.println("zhangsan@itcast.com".matches(regex1));
        System.out.println("---------11------");
        String regex2="[1-9]\\d{16}[\\dxX]";
        System.out.println("360122200607106349".matches(regex2));
        System.out.println("123456789012345678".matches(regex2));
        System.out.println("36012220070710123X".matches(regex2));
        System.out.println("-------12-------");
        String regex3="(?i)bc";
        String regex4="a(?i)bc";
        String regex5="a((?i)b)c";
        System.out.println("Bc".matches(regex3));//true
        System.out.println("AbC".matches(regex4));//false
        System.out.println("aBC".matches(regex4));//true
        System.out.println("aBc".matches(regex5));//true
        String str="Java自从95年间问世以来，经历了很多版本，目前企业中使用最多的版本是Java8和Java11,因为这两个是长期支持版本，下一个" +
                "长期支持版本是Java17,相信未来不久Java17也会登上历史的舞台";
        /*Pattern p=Pattern.compile("Java\\d{0,2}");
        Matcher m=p.matcher(str);
        boolean flag=m.find();
        System.out.println(flag);
        String s1=m.group();
        System.out.println(s1);*/
        Pattern p=Pattern.compile("Java\\d{0,2}");
        Matcher m=p.matcher(str);
        while(m.find()){
            String s=m.group();
            System.out.println(s);
        }
        System.out.println("-----------------");
        String regex6="Java(？=8||11||17)";
        String regex7="Java(?:8)";
        String regex8="Java(?!11||17)";
        Pattern p1=Pattern.compile(regex6);
        Matcher m1=p1.matcher(str);
        while(m1.find()){
            String s=m1.group();
            System.out.println(s);
        }
        System.out.println("--------------");
        Pattern p2=Pattern.compile(regex7);
        Matcher m2=p2.matcher(str);
        while(m2.find()){
            String s=m2.group();
            System.out.println(s);
        }
        System.out.println("--------------");
        Pattern p3=Pattern.compile(regex8);
        Matcher m3=p3.matcher(str);
        while(m3.find()){
            String s=m3.group();
            System.out.println(s);
        }
        String s="cheng abc yiyang";
        String result=s.replaceAll("[abc]+","vs");
        System.out.println(result);
        String[] arr=s.split("[abc]+");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        String regex01="(.).+\\1";
        String regex02="(.+).+\\1";
        String regex03="((.)\\2*).+\\1";
        System.out.println("a123a".matches(regex01));
        System.out.println("abc123abc".matches(regex02));
        System.out.println("aa123aaa".matches(regex03));


    }
}
